package Logic.EventSample.Goods.Collect;

import FrameWork.Event.Trigger;
import FrameWork.Model.Player;
import Logic.EventSample.Goods.Gain.GainGoodTrigger;
import Logic.EventSample.Goods.Gain.GainSource;
import Logic.EventSample.Goods.Use.UseGoodTrigger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 采集事件触发器
 */
@Component
public class CollectTrigger extends Trigger<CollectHandler> {

    @Autowired
    private GainGoodTrigger gainGoodTrigger;
    @Autowired
    private UseGoodTrigger useGoodTrigger;

    public void fire(Player player,int goodId,int cnt){
        //触发采集事件处理器
        for (CollectHandler handler:getEventHandlers()){
            handler.onCollect(player,goodId,cnt);
        }
        //触发道具获取事件触发器
        gainGoodTrigger.fire(player,goodId,cnt,GainSource.COLLECT);
        //触发道具使用事件触发器
        int collectEquipmentId = getCollectEquipmentId(player);
        useGoodTrigger.fire(player,collectEquipmentId,1);
    }

    //获取当前使用的采集道具ID
    public int getCollectEquipmentId(Player player){
        return 0;
    }

}
